#include <54func.h>
int main(int argc,char *argv[1])
{
    //任务：编写程序A和B。A负责将文件的名字、长度和内容通过管道发送B，B需要新建一个目录，并将该问价能存储起来
    // ./2_A 1.pipe file
    ARGS_CHECK(argc,3);
    int fdw_pipe = open(argv[1],O_WRONLY);
   ERROR_CHECK(fdw_pipe,-1,"open write");

    //发送文件名字
    write(fdw_pipe,argv[2],strlen(argv[2]));
    

    //发送文件内容
    char buf[4096] = {0};
    int fdr = open(argv[2],O_RDONLY);
    ERROR_CHECK(fdr,-1,"open read");
    ssize_t sret = read(fdr,buf,sizeof(buf));
    write(fdw_pipe,buf,sret);

    close(fdw_pipe);
    close(fdr);
        
    return 0;
}
